package com.zboin.framework.config;

import com.zboin.framework.interceptor.AuthInterceptor;
import com.zboin.framework.serve.TokenServe;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhboom
 * @date 2025/6/10 21:56
 */
@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {


    private final TokenServe tokenServe;

    public WebAppConfigurer(TokenServe tokenServe) {
        this.tokenServe = tokenServe;
    }

    @Bean
    public AuthInterceptor authInterceptor() {
        return new AuthInterceptor(tokenServe);
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authInterceptor())
                .addPathPatterns("/sys/**")
                .excludePathPatterns("/login", "/logout");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
